/**
 * @file       Singleton.h
 * @brief      
 * @author     LiuJkun
 * @version    1.0.0
 */

/*********************************************************************
 *  LiuJikun   08/15/2010      Initial Version
 *********************************************************************/

#ifndef  SINGLETON_INC
#define  SINGLETON_INC
template <class T>
class Singleton  {
    protected:
        static T *mInstance;
        Singleton(){
        }
        virtual ~Singleton() {
        }
    public:
        static T& instance() {
            if(mInstance == NULL) {
                mInstance = new T;
            }
            return *mInstance;
        }
    
};
template <class T>  T *Singleton<T>::mInstance = NULL;
#endif   // ----- #ifndef SINGLETON_INC  -----
